﻿<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <script type="text/javascript">
    <![CDATA[ var selected = null;
      var letters = new Array(5);
      letters[0] = 'A';
      letters[1] = 'B';
      letters[2] = 'C';
      letters[3] = 'D';
      letters[4] = 'E';
      
      var serviceUsers = '';
      var currentIndex;

      function selectService(arg)
      {
        unselectService();
        if(arg != '[object]') arg = document.getElementById(arg);
  
        //arg.className = 'leftsubNavItemSelected';
        arg.style.color = '#e52d87';
        document.getElementById('selectedService').value = arg.getAttribute('serviceName');
        selected = arg;
      }

      function unselectService()
      {
        if(selected && selected == '[object]')
        {
          selected.style.color = '#304500';
          //selected.className = 'leftsubNavItem';
          selected = null;
        }
        document.getElementById('selectedService').value = '';
      }

      function Reorder(eSelect, type, eOddSelect)
      {
        var eForm = eSelect.form;
        var iNewOrder = eSelect.selectedIndex + 1;
        var iPrevOrder = currentIndex + 1;
        var ix;

        var ViewOrder;
        var users = serviceUsers.split(';');
        users.pop();
        if(type == 'Row')
        {
          ViewOrder = new Array(users.length);
          for(i = 0; i < users.length; i++)
          {
            if(eForm['slcColumn_' + users[i]].selectedIndex == eForm[eOddSelect].selectedIndex)
            {
              ViewOrder[i] = 'slcRow_' + users[i];
            }
            else
            {
              ViewOrder[i] = '';
            }
          }
        }
        else if(type == 'Column')
        {
          ViewOrder = new Array(users.length);
          for(i = 0; i < users.length; i++)
          {
            if(eForm['slcRow_' + users[i]].selectedIndex == eForm[eOddSelect].selectedIndex)
            {
              ViewOrder[i] = 'slcColumn_' + users[i];
            }
            else
            {
              ViewOrder[i] = '';
            }
          }
        }
        
	      if (iNewOrder != iPrevOrder)
	      {
		      var iInc = iNewOrder > iPrevOrder? -1:1;
		      var iMin = Math.min(iNewOrder, iPrevOrder);
		      var iMax = Math.max(iNewOrder, iPrevOrder);
		      for (var iField = 0; iField < users.length; iField++)
		      {
			      if (ViewOrder[iField] != eSelect.name)
			      {
              if(ViewOrder[iField] != '')
              {
                if (eForm[ViewOrder[iField]].selectedIndex + 1 >= iMin &&
                    eForm[ViewOrder[iField]].selectedIndex + 1 <= iMax)
                {
                  eForm[ViewOrder[iField]].selectedIndex += iInc;
                }
              }
            }
          }
        }
        currentIndex = eSelect.selectedIndex;
     }
     
     function checkPositionAvailability(eSelect, newUser)
     {
        var eForm = eSelect.form;
        var users = serviceUsers.split(';');
        users.pop();
        var found = false;
        for(var i = 0; i < users.length; i++)
        {
          if(eForm['slcColumn_' + users[i]].selectedIndex == eForm['slcColumn_' + newUser].selectedIndex &&
             eForm['slcRow_' + users[i]].selectedIndex == eForm['slcRow_' + newUser].selectedIndex)
          {
              found = true;
          }
        }
        if(found)
        {
            document.getElementById('divError_' + newUser).style.display = 'block';
            document.getElementById('btnAdd_' + newUser).disabled = true;
        }
        else
        {
            document.getElementById('divError_' + newUser).style.display = 'none';
            document.getElementById('btnAdd_' + newUser).disabled = false;
        }
     }]]>
    </script>
    <input type="hidden" id="selectedService" name="selectedService" value="" />
    <input type="hidden" id="selectedUser" name="selectedUser" value="" />
    <input type="hidden" id="selectedRow" name="selectedRow" value="" />
    <input type="hidden" id="selectedButton" name="selectedButton" value="" />
    <table style="width:100%">
      <tr>
        <td colspan="3" style="text-align:right">
          <input type="button" name="btnValidate" value=" Valider " onclick="javascript:document.getElementById('selectedButton').value = this.name;this.form.submit();" />
          <!--<a name="btnValidate" onclick="javascript:document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Valider</a>-->
        </td>
      </tr>
      <tr>
        <td style="width:25%;vertical-align:top;">
          <table style="width:100%;vertical-align:top;">
            <tr>
              <td style="width:100%;vertical-align:top;padding-bottom:20px;">
                <table style="width:100%;vertical-align:top;">
                  <tr class="ms-WPHeader">
                    <td id="WebPartTitleWPQ3" title="Trombinoscope" style="WIDTH: 100%">
                      <h3 class="ms-standardheader ms-WPTitle">
                        <nobr>
                          <span style="font-size:10pt">Trombinoscope</span>
                          <span id="WebPartCaptionWPQ3"></span>
                        </nobr>
                      </h3>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr>
              <td class="leftNavBG" style="width:100%;vertical-align:top;">
                <table class="leftNav" cellSpacing="0" cellPadding="0" border="0" style="width:100%;border:0px;">
                  <tr>
                    <td>
                      <table class="leftNavItem" cellSpacing="0" cellPadding="0" style="width:100%;" border="0">
                        <tr>
                          <td style="WIDTH: 100%; WHITE-SPACE: nowrap">
                            <span class="leftNavItem" style="FONT-SIZE: 1em; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none;padding-left:5px;">Les tribus VP</span>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                  <xsl:apply-templates select="/Services/Service" mode="Left" />
                </table>
              </td>
            </tr>
          </table>
        </td>
        <td class="trombiMiddle" style="width:50%;">
          <table style="width:100%;height:100%;">
            <tr>
              <td colspan="7" class="trombiMiddleHeader">
                <xsl:value-of select="descendant::Service[@Selected = 'True']/@Name"/>
              </td>
            </tr>
            <tr>
              <td style="text-align:center">&amp;nbsp;</td>
              <xsl:call-template name="ForLoop-TableHeader">
                <xsl:with-param name="i" select="0" />
                <xsl:with-param name="count" select="//ColumnCount - 1" />
              </xsl:call-template>
              <td style="text-align:center">&amp;nbsp;</td>
            </tr>
            <xsl:apply-templates select="descendant::Service[@Selected = 'True']" mode="Middle" />
            <tr>
              <td noWrap="true" style="width:100%;text-align:right">
                <xsl:attribute name="colSpan">
                  <xsl:value-of select="//ColumnCount + 2"/>
                </xsl:attribute>
                <!--<input type="button" name="btnNewRow" value=" NewRow " onclick="javascript:document.getElementById('selectedButton').value = this.name;this.form.submit();" />-->
                <a name="btnNewRow" onclick="javascript:document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Nouvelle ligne</a>
              </td>
            </tr>
          </table>
        </td>
        <td style="width:25%;vertical-align:top">
          <table>
            <tr>
              <td>
                <div style="height:400px;border:solid 2px gray;overflow-y:scroll">
                  <table>
                    <!--<xsl:apply-templates select="/Services/Service" mode="TopRight" />-->
                    <xsl:apply-templates select="descendant::Service[@Selected = 'True']/User" mode="Right" >
						<xsl:sort select="@LastName" order="ascending"/>
						<xsl:sort select="@FirstName" order="ascending"/>
					</xsl:apply-templates>
                  </table>
                </div>
                <div style="text-align:right">
                  <input type="button" name="btnUpdate" value=" Mettre à jour " onclick="javascript:document.getElementById('selectedButton').value = this.name;this.form.submit();" />
                  <!--<a name="btnUpdate" onclick="javascript:document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Mettre à jour</a>-->
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <div style="height:400px;border:solid 2px gray;overflow-y:scroll">
                  <table>
                    <xsl:apply-templates select="descendant::Service[@Selected = 'True']/NewUser[@IsInMultipleService='False']" />
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <div style="height:400px;border:solid 2px gray;overflow-y:scroll">
                  <table>
                    <xsl:apply-templates select="descendant::Service[@Selected = 'True']/NewUser[@IsInMultipleService='True']" />
                  </table>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td colspan="3" style="text-align:right">
          <input type="button" name="btnValidate" value=" Valider " onclick="javascript:document.getElementById('selectedButton').value = this.name;this.form.submit();" />
          <!--<a name="btnValidate" onclick="javascript:document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Valider</a>-->
        </td>
      </tr>
    </table>
  </xsl:template>
  
  <!-- Left -->
  <xsl:template match="/Services/Service" mode="Left">
    <tr>
      <td>
        <table cellSpacing="0" cellPadding="0" width="100%" border="0">
          <tr>
            <td>
              <table class="leftsubNavItem" cellSpacing="0" cellPadding="0" width="100%" border="0">
                <tr>
                  <td class="leftsubNavItem">
                    <xsl:attribute name="style">
                      <xsl:choose>
                        <xsl:when test="position() != 1">
                          <![CDATA[width: 100%; white-space: nowrap;border-top:solid 1px #c5da8b]]>
                        </xsl:when>
                        <xsl:otherwise>
                          <![CDATA[width: 100%; white-space: nowrap]]>
                        </xsl:otherwise>
                      </xsl:choose>
                    </xsl:attribute>
                    <span class="leftsubNavItem" style="cursor:pointer;font-size: 1em; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none;text-transform: uppercase;font-weight: bold;" onclick="javascript:selectService(this.getAttribute('id'));document.forms[0].submit();">
                      <xsl:attribute name="serviceName">
                        <xsl:value-of select="@Name" />
                      </xsl:attribute>
                      <xsl:choose>
                        <xsl:when test="@Selected = 'True'">
                          <xsl:attribute name="id">selected</xsl:attribute>
                          <script type="text/javascript">
                            selectService('selected');
                          </script>
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:attribute name="id">
                            <xsl:value-of select="concat('service_', @Name, '_', @DirectionCssName)"/>
                          </xsl:attribute>
                        </xsl:otherwise>
                      </xsl:choose>
                      <xsl:value-of select="@Name" />
                    </span>
                  </td>
                </tr>
                <xsl:if test="count(current()/Service) > 0">
                  <tr>
                    <td class="leftsubNavItem" style="width: 100%; white-space: nowrap; padding-left:10px">
                      <xsl:apply-templates select="Service" mode="LeftLevel2" />
                    </td>
                  </tr>
                </xsl:if>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </xsl:template>
  <!--<xsl:template match="Service/Service" mode="Left">
    <table class="leftsubNavItem" cellSpacing="0" cellPadding="0" width="100%" border="0">
      <tr>
        <td class="leftsubNavItem" style="width: 100%; white-space: nowrap">
          <span class="leftsubNavItem" style="cursor:pointer;font-size: 1em; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none" onclick="javascript:selectService(this.getAttribute('id'));document.forms[0].submit();">
            <xsl:attribute name="serviceName">
              <xsl:value-of select="@Name" />
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="@Selected = 'True'">
                <xsl:attribute name="id">selected</xsl:attribute>
                <script type="text/javascript">
                  selectService('selected');
                </script>
              </xsl:when>
              <xsl:otherwise>
                <xsl:attribute name="id">
                  <xsl:value-of select="concat('service_', @Name, '_', @DirectionCssName)"/>
                </xsl:attribute>
              </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="@Name" />
          </span>
        </td>
      </tr>
      <xsl:if test="count(current()/Service) > 0">
        <tr>
          <td class="leftsubNavItem" style="width: 100%; white-space: nowrap; padding-left:10px">
            <xsl:apply-templates select="Service" mode="Left" />
          </td>
        </tr>
      </xsl:if>
    </table>
  </xsl:template>-->
  <xsl:template match="Service" mode="LeftLevel2">
    <table class="leftsubNavItem" cellSpacing="0" cellPadding="0" width="100%" border="0">
      <tr>
        <td class="leftsubNavItem" style="width: 100%; white-space: nowrap">
          <span class="leftsubNavItem" style="cursor:pointer;font-size: 1em; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none;font-weight: bold;" onclick="javascript:selectService(this.getAttribute('id'));document.forms[0].submit();">
            <xsl:attribute name="serviceName">
              <xsl:value-of select="@Name" />
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="@Selected = 'True'">
                <xsl:attribute name="id">selected</xsl:attribute>
                <script type="text/javascript">
                  selectService('selected');
                </script>
              </xsl:when>
              <xsl:otherwise>
                <xsl:attribute name="id">
                  <xsl:value-of select="concat('service_', @Name, '_', @DirectionCssName)"/>
                </xsl:attribute>
              </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="@Name" />
          </span>
        </td>
      </tr>
      <xsl:if test="count(current()/Service) > 0">
        <tr>
          <td class="leftsubNavItem" style="width: 100%; white-space: nowrap; padding-left:10px">
            <xsl:apply-templates select="Service" mode="LeftLevel3" />
          </td>
        </tr>
      </xsl:if>
    </table>
  </xsl:template>
  <xsl:template match="Service" mode="LeftLevel3">
    <table class="leftsubNavItem" cellSpacing="0" cellPadding="0" width="100%" border="0">
      <tr>
        <td class="leftsubNavItem" style="width: 100%; white-space: nowrap">
          <span class="leftsubNavItem" style="cursor:pointer;font-size: 1em; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none;" onclick="javascript:selectService(this.getAttribute('id'));document.forms[0].submit();">
            <xsl:attribute name="serviceName">
              <xsl:value-of select="@Name" />
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="@Selected = 'True'">
                <xsl:attribute name="id">selected</xsl:attribute>
                <script type="text/javascript">
                  selectService('selected');
                </script>
              </xsl:when>
              <xsl:otherwise>
                <xsl:attribute name="id">
                  <xsl:value-of select="concat('service_', @Name, '_', @DirectionCssName)"/>
                </xsl:attribute>
              </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="@Name" />
          </span>
        </td>
      </tr>
      <xsl:if test="count(current()/Service) > 0">
        <tr>
          <td class="leftsubNavItem" style="width: 100%; white-space: nowrap; padding-left:10px">
            <xsl:apply-templates select="Service" mode="LeftLevel3" />
          </td>
        </tr>
      </xsl:if>
    </table>
  </xsl:template>
  
  <!-- Middle -->
  <xsl:template match="Service" mode="Middle">
    <xsl:call-template name="ForLoop-Row">
      <xsl:with-param name="i" select="0" />
      <xsl:with-param name="count" select="//RowCount - 1" />
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="Service/User" mode="Middle">
    <xsl:param name="i" />
    <xsl:param name="j" />
    <!--<![CDATA[ <img src="]]><xsl:value-of select="@PictureURL" /><![CDATA[" width="120" />]]>-->
    <![CDATA[ <img src="]]><xsl:value-of select="@PictureURL" /><![CDATA[" />]]>
    <span class="trombiInfoPrenom">
      <xsl:value-of select="@FirstName" />
    </span>
    <span class="trombiInfoNom">
      <xsl:value-of select="@LastName" />
    </span>
    <span class="trombiInfo">
      <xsl:value-of select="@Title" />
    </span>
    <xsl:choose>
      <xsl:when test="normalize-space(@IsManager) = 'True'">
        <![CDATA[<hr class="]]><xsl:value-of select="concat('trombiSeparatorManager-', current()/parent::node()/@DirectionCssName)"/><![CDATA[" />]]>
      </xsl:when>
      <xsl:otherwise>
        <![CDATA[<hr class="]]><xsl:value-of select="concat('trombiSeparator-', current()/parent::node()/@DirectionCssName)"/><![CDATA[" />]]>
      </xsl:otherwise>
    </xsl:choose>
    <span class="trombiInfoFooter">
      <xsl:value-of select="@WorkPhone" />
    </span>
        <script type="text/javascript">
          document.write(letters[<xsl:value-of select="$j"/>]);
        </script>
	   <xsl:value-of select="$i + 1"/> 
	   <br />

    <div style="width:100%;text-align:right">
      <![CDATA[<input type="button" name="btnDelete" value=" Supprimer " onclick="javascript:document.getElementById('selectedUser').value = ']]><xsl:value-of select="@UserProfile_GUID" /><![CDATA[';document.getElementById('selectedButton').value = this.name;this.form.submit();" />]]>
    </div>
  </xsl:template>
  <xsl:template name="ForLoop-TableHeader">
    <xsl:param name="i" />
    <xsl:param name="count" />
    <!--begin_: Line_by_Line_Output -->
    <xsl:if test="$i &lt;= $count">
      <td style="text-align:center">
        <script type="text/javascript">
          document.write(letters[<xsl:value-of select="$i"/>]);
        </script>
      </td>
    </xsl:if>
    <!--begin_: RepeatTheLoopUntilFinished-->
    <xsl:if test="$i &lt;= $count">
      <xsl:call-template name="ForLoop-TableHeader">
        <xsl:with-param name="i" select="$i + 1" />
        <xsl:with-param name="count" select="$count" />
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <xsl:template name="ForLoop-Row">
    <xsl:param name="i" />
    <xsl:param name="count" />
    <!--begin_: Line_by_Line_Output -->
    <xsl:if test="$i &lt;= $count">
      <tr>
        <td>
          <xsl:value-of select="$i + 1"/>
        </td>
        <xsl:call-template name="ForLoop-Column">
          <xsl:with-param name="i" select="$i"/>
          <xsl:with-param name="j" select="0" />
          <xsl:with-param name="count" select="//ColumnCount - 1"/>
        </xsl:call-template>
        <td>
          <table cellSpacing="10">
            <tr>
              <td noWrap="true">
                <!--<![CDATA[<input type="button" name="btnInsertBefore" value=" Insérer une ligne avant " onclick="javascript:document.getElementById('selectedRow').value = ']]><xsl:value-of select="$i"/><![CDATA[';document.getElementById('selectedButton').value = this.name;this.form.submit();" />]]>-->
                <![CDATA[<a name="btnInsertBefore" onclick="javascript:document.getElementById('selectedRow').value = ']]><xsl:value-of select="$i"/><![CDATA[';document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Insérer une ligne avant</a>]]>
              </td>
            </tr>
            <tr>
              <td noWrap="true">
                <!--<![CDATA[<input type="button" name="btnRealign" value=" Réaligner avec les lignes précédentes " onclick="javascript:document.getElementById('selectedRow').value = ']]><xsl:value-of select="$i"/><![CDATA[';document.getElementById('selectedButton').value = this.name;this.form.submit();" />]]>-->
                <![CDATA[<a name="btnRealign" onclick="javascript:document.getElementById('selectedRow').value = ']]><xsl:value-of select="$i"/><![CDATA[';document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Réaligner avec les lignes précédentes</a>]]>
              </td>
            </tr>
            <tr>
              <td noWrap="true">
                <!--<![CDATA[<input type="button" name="btnDeleteRow" value=" Supprimer la ligne " onclick="javascript:document.getElementById('selectedRow').value = ']]><xsl:value-of select="$i"/><![CDATA[';document.getElementById('selectedButton').value = this.name;this.form.submit();" />]]>-->
                <![CDATA[<a name="btnDeleteRow" onclick="javascript:document.getElementById('selectedRow').value = ']]><xsl:value-of select="$i"/><![CDATA[';document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Supprimer la ligne</a>]]>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </xsl:if>
    <!--begin_: RepeatTheLoopUntilFinished-->
    <xsl:if test="$i &lt;= $count">
      <xsl:call-template name="ForLoop-Row">
        <xsl:with-param name="i" select="$i + 1"/>
        <xsl:with-param name="count" select="$count"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <xsl:template name="ForLoop-Column">
    <xsl:param name="i" />
    <xsl:param name="j" />
    <xsl:param name="count" />
    <!--begin_: Line_by_Line_Output -->
    <xsl:if test="$j &lt;= $count">
      <td style="vertical-align:top;width:122px;text-align:center">
        <div class="trombiEmpty">
          <xsl:choose>
            <xsl:when test="normalize-space(User[@RowNumber = $i and @ColumnNumber = $j]/@IsManager) = 'True'">
              <xsl:attribute name="class">
                <xsl:value-of select="concat('trombiManager-', @DirectionCssName)"/>
              </xsl:attribute>
            </xsl:when>
            <xsl:when test="normalize-space(User[@RowNumber = $i and @ColumnNumber = $j]/@IsManager) = 'False'">
              <xsl:attribute name="class">
                <xsl:value-of select="concat('trombi-', @DirectionCssName)"/>
              </xsl:attribute>
            </xsl:when>
          </xsl:choose>
          <xsl:apply-templates select="User[@RowNumber = $i and @ColumnNumber = $j]" mode="Middle" >
			<xsl:with-param name="i" select="$i"/>
			<xsl:with-param name="j" select="$j"/>
		  </xsl:apply-templates>
        </div>
      </td>
    </xsl:if>
    <!--begin_: RepeatTheLoopUntilFinished-->
    <xsl:if test="$j &lt;= $count">
      <xsl:call-template name="ForLoop-Column">
        <xsl:with-param name="i" select="$i"/>
        <xsl:with-param name="j" select="$j + 1"/>
        <xsl:with-param name="count" select="$count"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  
  <!-- Top Right -->
  <xsl:template match="Service/User" mode="Right">
    <tr>
      <td>
        <![CDATA[ <img src="]]><xsl:value-of select="@PictureURL" /><![CDATA[" />]]>
        <br />
        <span>
          <xsl:value-of select="@FirstName" />
        </span>
        <br />
        <span>
          <xsl:value-of select="@LastName" />
        </span>
        <br />
        <table>
          <tr>
            <td style="text-align:center">
              <select>
                <xsl:attribute name="name">
                  <xsl:value-of select="concat('slcColumn_', @UserProfile_GUID)"/>
                </xsl:attribute>
                <xsl:attribute name="onchange">
                  <![CDATA[Reorder(this, 'Column', ']]><xsl:value-of select="concat('slcRow_', @UserProfile_GUID)" /><![CDATA[');]]>
                </xsl:attribute>
                <xsl:attribute name="onfocus">
                  <![CDATA[currentIndex = this.selectedIndex;]]>
                </xsl:attribute>
                <xsl:call-template name="ForLoop-ColumnOption">
                  <xsl:with-param name="i" select="0" />
                  <xsl:with-param name="count" select="//ColumnCount - 1"/>
                  <xsl:with-param name="columnNumber" select="@ColumnNumber"/>
                </xsl:call-template>
              </select>
            </td>
            <td style="text-align:center">
              <select>
                <xsl:attribute name="name">
                  <xsl:value-of select="concat('slcRow_', @UserProfile_GUID)"/>
                </xsl:attribute>
                <xsl:attribute name="onchange">
                  <![CDATA[Reorder(this, 'Row', ']]><xsl:value-of select="concat('slcColumn_', @UserProfile_GUID)" /><![CDATA[');]]>
                </xsl:attribute>
                <xsl:attribute name="onfocus">
                  <![CDATA[currentIndex = this.selectedIndex;]]>
                </xsl:attribute>
                <xsl:call-template name="ForLoop-RowOption">
                  <xsl:with-param name="i" select="0" />
                  <xsl:with-param name="count" select="//RowCount - 1"/>
                  <xsl:with-param name="rowNumber" select="@RowNumber"/>
                </xsl:call-template>
              </select>
            </td>
          </tr>
        </table>
        <br/>
        <span>
          <script type="text/javascript">
            <![CDATA[ serviceUsers += ']]><xsl:value-of select="@UserProfile_GUID"/><![CDATA[' + ';';]]>
          </script>
        </span>
      </td>
    </tr>
  </xsl:template>
  
  <!-- Bottom Right -->
  <xsl:template match="Service/NewUser">
    <tr>
      <td>
        <![CDATA[ <img src="]]><xsl:value-of select="@PictureURL" /><![CDATA[" />]]>
        <br />
        <span>
          <xsl:value-of select="@FirstName" />
        </span>
        <br />
        <span>
          <xsl:value-of select="@LastName" />
        </span>
        <br />
        <table>
          <tr>
            <td style="text-align:center">
              <select>
                <xsl:attribute name="name">
                  <xsl:value-of select="concat('slcColumn_', @UserProfile_GUID)"/>
                </xsl:attribute>
                <xsl:attribute name="onchange">
                  <![CDATA[javascript:checkPositionAvailability(this, ']]><xsl:value-of select="@UserProfile_GUID"/><![CDATA[');]]>
                </xsl:attribute>
                <xsl:call-template name="ForLoop-ColumnOption">
                  <xsl:with-param name="i" select="0" />
                  <xsl:with-param name="count" select="//ColumnCount - 1"/>
                  <xsl:with-param name="columnNumber" select="@ColumnNumber"/>
                </xsl:call-template>
              </select>
            </td>
            <td style="text-align:center">
              <select>
                <xsl:attribute name="name">
                  <xsl:value-of select="concat('slcRow_', @UserProfile_GUID)"/>
                </xsl:attribute>
                <xsl:attribute name="onchange">
                  <![CDATA[javascript:checkPositionAvailability(this, ']]><xsl:value-of select="@UserProfile_GUID"/><![CDATA[');]]>
                </xsl:attribute>
                <xsl:call-template name="ForLoop-RowOption">
                  <xsl:with-param name="i" select="0" />
                  <xsl:with-param name="count" select="//RowCount - 1"/>
                  <xsl:with-param name="rowNumber" select="@RowNumber"/>
                </xsl:call-template>
              </select>
            </td>
          </tr>
        </table>
        <br />
        <div style="display:none">
          <xsl:attribute name="id">
            <xsl:value-of select="concat('divError_', @UserProfile_GUID)" />
          </xsl:attribute>
          Une personne se trouve à cette position, veuillez la modifier.
        </div>
        <div style="text-align:right">
          <![CDATA[<input id="]]><xsl:value-of select="concat('btnAdd_', @UserProfile_GUID)" /><![CDATA[" type="button" name="btnAdd" value=" Ajouter " onfocus="javascript:checkPositionAvailability(this, ']]><xsl:value-of select="@UserProfile_GUID" /><![CDATA[');" onclick="javascript:document.getElementById('selectedUser').value = ']]><xsl:value-of select="@UserProfile_GUID" /><![CDATA[';document.getElementById('selectedButton').value = this.name;this.form.submit();" />]]>
          <!--<![CDATA[<a id="]]><xsl:value-of select="concat('btnAdd_', @UserProfile_GUID)" /><![CDATA[" name="btnAdd" value=" Add " onfocus="javascript:checkPositionAvailability(this, ']]><xsl:value-of select="@UserProfile_GUID" /><![CDATA[');" onclick="javascript:document.getElementById('selectedUser').value = ']]><xsl:value-of select="@UserProfile_GUID" /><![CDATA[';document.getElementById('selectedButton').value = this.name;" href="javascript:document.forms[0].submit();">Ajouter l'utilisateur</a>]]>-->
        </div>
      </td>
    </tr>
  </xsl:template>

  <xsl:template name="ForLoop-RowOption">
    <xsl:param name="i" />
    <xsl:param name="count" />
    <xsl:param name="rowNumber" />
    <!--begin_: Line_by_Line_Output -->
    <xsl:if test="$i &lt;= $count">
      <option>
        <xsl:attribute name="value">
          <xsl:value-of select="$i" />
        </xsl:attribute>
        <xsl:if test="$rowNumber = $i">
          <xsl:attribute name="selected">selected</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="$i + 1"/>
      </option>
    </xsl:if>
    <!--begin_: RepeatTheLoopUntilFinished-->
    <xsl:if test="$i &lt;= $count">
      <xsl:call-template name="ForLoop-RowOption">
        <xsl:with-param name="i" select="$i + 1"/>
        <xsl:with-param name="count" select="$count"/>
        <xsl:with-param name="rowNumber" select="$rowNumber"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <xsl:template name="ForLoop-ColumnOption">
    <xsl:param name="i" />
    <xsl:param name="count" />
    <xsl:param name="columnNumber" />
    <!--begin_: Line_by_Line_Output -->
    <xsl:if test="$i &lt;= $count">
      <option>
        <xsl:attribute name="value">
          <xsl:value-of select="$i" />
        </xsl:attribute>
        <xsl:if test="$columnNumber = $i">
          <xsl:attribute name="selected">selected</xsl:attribute>
        </xsl:if>
        <script type="text/javascript">
          document.write(letters[<xsl:value-of select="$i"/>]);
        </script>
      </option>
    </xsl:if>
    <!--begin_: RepeatTheLoopUntilFinished-->
    <xsl:if test="$i &lt;= $count">
      <xsl:call-template name="ForLoop-ColumnOption">
        <xsl:with-param name="i" select="$i + 1"/>
        <xsl:with-param name="count" select="$count"/>
        <xsl:with-param name="columnNumber" select="$columnNumber"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>